import request from '@/utils/request';
import { stringify } from 'qs';
import { toFormData } from '@/utils/utils.jsx';


/********网店商品的接口 */

//店铺名称模糊
export async function getStoreName() {
  return request(`/zjf-erp-spd/spdPrint/fetchRemoteStoreList`);
}

//网店商品列表
export async function getGoodList(params) {
  return request(`/blade-goods/ecAllgoods/list/pageEcGoods?${stringify(params)}`
  );
}

// 商品修改渠道
export async function getchangeChannel(params) {
  return request('/blade-goods/ecAllgoods/modifyProductChannel', {
    method: 'POST',
    body: toFormData(params),
  });
}

//修改商品类型
export async function changeStatus(params) {
  return request('/blade-goods/ecAllgoods/setUpTakeOrGet', {
    method: 'POST',
    data: params,
  });
}

// 匹配单条修改状态 影响数量
export async function affect(params) {
  return request(
    `/blade-goods/ecAllgoods/queryImpactNumber?${stringify(params)}`
  );
}



/**********系统商品接口 */

//系统商品列表
export async function getSystemGoodList(params) {
  return request(`/blade-goods/sysAllgoods/list/pageSysGoods?${stringify(params)}`
  );
}

// 商品修改渠道
export async function changeSysChannel(params) {
  return request('/blade-goods/sysAllgoods/modifyProductChannel', {
    method: 'POST',
    body: toFormData(params),
  });
}

// 匹配单条修改状态 影响数量
export async function macthInfluence(params) {
  return request(`/blade-goods/sysAllgoods/queryImpactNumber?${stringify(params)}`);
}

//修改商品类型
export async function changeSysGoodsType(params) {
  return request('/blade-goods/sysAllgoods/setUpTakeOrGet', {
    method: 'POST',
    data: params,
  });
}



/*********公共接口 */

// 获取渠道下拉
export async function getChannelList(params) {
  return request(`/zjf-wms/channel/queryTypeChannel?${stringify(params)}`);
}

//获取智能设置信息
export async function getGoodsSet() {
  return request(`/blade-user/usercfg/getReadProductIntelligent`);
}

//设置智能设置
export async function setGoodsSet(params) {
  return request('/blade-user/usercfg/readProductIntelligent', {
    method: 'POST',
    // data: params
    body: toFormData(params),
  });
}

// 初始化智能配置
export async function init(params) {
  return request(
    `/blade-goods/smartchannelconfig/getInitChannelId?${stringify(params)}`
  );
}

// 修改初始化智能配置
export async function changeInit(params) {
  return request('/blade-goods/smartchannelconfig/update', {
    method: 'POST',
    data: params,
  });
}

// 商品类型修改对订单影响的数量和商品
export async function queryChannelStatistic(params) {
  return request('/zjf-oms/order/goods/channel/statistics', {
    method: 'POST',
    data: params,
  });
}

// 商品类型修改对订单影响的提交确定
export async function updateOrderGoods(params) {
  return request('/zjf-oms/order/goods/channel/update', {
    method: 'POST',
    data: params,
  });
}

// 匹配修改状态 影响数量
export async function affectNums(params) {
    return request(
      `/blade-goods/sysOrEcGoods/queryImpactNumber?${stringify(params)}`
    );
  }

// 根据uuid查询用户合格证
export async function queryCofoTemplateByUuid(params) {
    return request(
      `/blade-goods/ecGoodsCofcTemplate/queryCofoTemplateByUuid?${stringify(params)}`
    );
  }

// 系统商品/网店商品 设置合格证
export async function setUpCertificate(params) {
    return request('/blade-goods/sysOrEcGoods/setUpCertificate', {
      method: 'POST',
      data: params,
    });
  }

  // 删除用户合格证
export async function delUpCertificate(params) {
    return request(
      `/blade-goods/sysOrEcGoods/delUpCertificate?${stringify(params)}`
    );
  }

// 下拉列表KV加载(拿货模板)
export async function queryTakeGoodsPrintTemplate(params) {
    return request(
      `/zjf-wms/takeGoodsPrintTemplate/selectKv?${stringify(params)}`
    );
  }

  // 系统商品/网店商品 设置拿货模板
export async function setTakeTemplate(params) {
    return request('/blade-goods/sysOrEcGoods/setTakeTemplate', {
      method: 'POST',
      data: params,
    });
  }

  // 系统商品/网店商品 删除拿货模板
  export async function delTakeTemplate(params) {
    return request(
      `/blade-goods/sysOrEcGoods/delTakeTemplate?${stringify(params)}`
    );
  }